<%--
  Created by IntelliJ IDEA.
  User: WJ
  Date: 2017/12/12
  Time: 15:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false"%>
<script src="js/jquery-3.2.1.min.js"></script>
<html>
<head>
    <title>Attendance Result</title>
</head>
<body>
    <h2>${msg}</h2>
    <button id = "findAllAddress">查询所有通讯录信息</button>
    <div id="content">
        <table id="addressAll" border="1"cellspacing="0">

        </table>
    </div>
    <input type="text" placeholder="请输入工号" name="workNum" id="workNum"/><button id="btnWork">搜索</button>
    <div id="content2">
        <table id="addressByWorkNum" border="1"cellspacing="0">

        </table>
    </div>
    <a href="homepage">返回</a>
</body>
<script>
    $("#findAllAddress").click(function(){
        $.get("findAllAddress",function(result){
            $("#addressAll").html("");
            $("#addressAll").html("<tr><td>工号</td><td>手机号</td><td>群名称</td></tr>");
            for(var i=0;i<result.length;i++){
                var tr = $("<tr></tr>");
                var td = $("<td>"+result[i].workNum+ "</td><td>"+result[i].phoneId+"</td><td>"+result[i].groupName+"</td>");
                tr.append(td);
                $("#addressAll").append(tr);
            }
        })
    })
    $("#btnWork").click(function(){
        $.post("findAddressByWorkNum",{workNum:$("#workNum").val()},function(result){
            $("#addressByWorkNum").html("");
            $("#addressByWorkNum").html("<tr><td>工号</td><td>手机号</td><td>群名称</td></tr>");
            for(var i=0;i<result.length;i++){
                var tr = $("<tr></tr>");
                var td = $("<td>"+result[i].workNum+ "</td><td>"+result[i].phoneId+"</td><td>"+result[i].groupName+"</td>");
                tr.append(td);
                $("#addressByWorkNum").append(tr);
            }
        })
    })
</script>
</html>
